<?php
namespace lightblog\home\model;

use lightblog\engine\activeRecord;

class aboutModel extends activeRecord {
    public function addContactMessage() {
        $post = \lightblog::$app->request->parameter->post;

        $name = $post['name'];
        $email = $post['email'];
        $content = $post['content'];
        $time = date('Y-m-d H:i:s');

        if ($this->validate($post)) {
            $sql_fields = "`name`, `email`, `time`, `content`";
            $sql_values = "'$name', '$email', '$time', '$content'";
            $sql = "INSERT INTO `contact` ($sql_fields) VALUES ($sql_values)";
            $res = $this->insert($sql);
            return $res;
        }
        return false;
    }

    /** 通用场景验证函数
     */
    public function validate_all($data) {
        return true;
    }
}
